﻿using System.IO;

namespace Gamey.SNES
{
    public class SnesGameLoader
    {
        public GameyDataSet.SnesGamesDataTable LoadGames()
        {
            var dataSet = new GameyDataSet();

            var romsDirectory = new DirectoryInfo(Env.Settings.ZsnesRomsPath);
            var smcHeaderReader = new SmcHeaderReader();
            foreach (FileInfo romFile in romsDirectory.EnumerateFiles("*.zip"))
            {
                var row = dataSet.SnesGames.NewSnesGamesRow();
                row.File = romFile.Name;

                SnesRomInfo info = smcHeaderReader.ReadZipFile(romFile.FullName);
                row.Name = info.Name;

                dataSet.SnesGames.AddSnesGamesRow(row);
            }

            return dataSet.SnesGames;
        }
    }
}
